import 'package:url_launcher/url_launcher.dart';

class TelAndSmsService {

  void emailTo(String email) {
    final Uri emailLaunchUri = Uri(
      scheme: 'mailto',
      path: email,
      query: encodeQueryParameters(<String, String>{
        'subject': '',
      }),
    );

    launchUrl(emailLaunchUri);
  }
  void telTo(String phone){
    final Uri telLaunchUri = Uri(
      scheme: 'tel',
      path: phone,
    );
    launchUrl(telLaunchUri);
  }
  void httpTo(String url){
    final Uri httpLaunchUri = Uri.http(url);
    launchUrl(httpLaunchUri);
  }

  String? encodeQueryParameters(Map<String, String> params) {
    return params.entries
        .map((MapEntry<String, String> e) =>
    '${Uri.encodeComponent(e.key)}=${Uri.encodeComponent(e.value)}')
        .join('&');
  }
}